﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;
using System.Data;

namespace WebApplication2
{
    public partial class updatestudent : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
            
        }

        private void bind()
        {
            int sno = Convert.ToInt32(Request.QueryString["sno"]);
            student model = studentBLL.getID(sno);
            txt_sno.Text =Convert.ToString(model.sno);
            txt_pwd.Text = model.password;
            txt_name.Text = model.name;
            txt_age.Text = model.age;
            RadioButtonList1.SelectedValue = model.sex;
            txt_bir.Text = model.birthtime;
            txt_add.Text = model.addres;
            txt_class.Text = model.classes;
            txt_tel.Text = model.tel;
            txt_zhuanye.Text = model.zhuanye;
            txt_qk.Text = model.graduation;
            txt_sno.Enabled = false;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            student model = new student();
            model.sno = Convert.ToInt32(txt_sno.Text);
            model.password = txt_pwd.Text;
            model.name = txt_name.Text;
            model.age = txt_age.Text;
            model.sex = RadioButtonList1.SelectedValue;
            model.birthtime = txt_bir.Text;
            model.addres = txt_add.Text;
            model.classes = txt_class.Text;
            model.tel = txt_tel.Text;
            model.zhuanye = txt_zhuanye.Text;
            model.graduation = txt_qk.Text;
            if (studentBLL.updatestu(model) > 0)
            {
                Response.Write("<script>alert('修改成功')</script>");

            }
            else
            {
                Response.Write("<script>alert('修改失败')</script>");
            }

        }
    }
}